<?php

namespace App\Admin\Controllers;

use App\Admin\Repositories\StoreOrder;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;

class StoreOrderController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * 何家令
     * 11.17
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new StoreOrder(), function (Grid $grid) {
            $grid->column('id')->sortable();
            $grid->column('order_id');
            $grid->column('uid');
            $grid->column('real_name');
            $grid->column('user_phone');
            $grid->column('user_address');
            $grid->column('cart_id');
            $grid->column('freight_price');
            $grid->column('total_num');
            $grid->column('total_price');
            $grid->column('total_postage');
            $grid->column('pay_price');
            $grid->column('pay_postage');
            $grid->column('deduction_price');
            $grid->column('coupon_id');
            $grid->column('coupon_price');
            $grid->column('paid');
            $grid->column('pay_time');
            $grid->column('pay_type');
            $grid->column('add_time');
            $grid->status
                ->using([-1 => '申请退款', -2 => '退货成功',0=>'待发货',1=>'待收货',2=>'已收货',3=>'待评价'])
                ->dot(
                    [
                        -1 => 'success',
                        -2 => 'danger',
                        0 => 'success',
                        1 => 'danger',
                        2 => 'success',
                        3 => 'danger'
                    ],
                    'primary' // 默认颜色
                );
            $grid->column('refund_status');
            $grid->column('refund_reason_wap_img');
            $grid->column('refund_reason_wap_explain');
            $grid->column('refund_reason_time');
            $grid->column('refund_reason_wap');
            $grid->column('refund_reason');
            $grid->column('refund_price');
            $grid->column('delivery_name');
            $grid->column('delivery_type');
            $grid->column('delivery_id');
            $grid->column('mark');
            $grid->column('is_del');
            $grid->column('remark');
            $grid->column('mer_id');
            $grid->column('is_mer_check');
            $grid->column('combination_id');
            $grid->column('pink_id');
            $grid->column('cost');
            $grid->column('seckill_id');
            $grid->column('bargain_id');
            $grid->column('store_id');
            $grid->column('shipping_type');
            $grid->column('is_channel');
            $grid->column('is_remind');
            $grid->column('is_system_del');
            $grid->column('pid');
            $grid->column('goods_id');
            $grid->column('order_name');
            $grid->column('created_at');
            $grid->column('updated_at')->sortable();
            $grid->filter(function (Grid\Filter $filter) {
                $filter->equal('id');

            });
        });
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     *
     * @return Show
     */
    protected function detail($id)
    {
        return Show::make($id, new StoreOrder(), function (Show $show) {
            $show->field('id');
            $show->field('order_id');
            $show->field('uid');
            $show->field('real_name');
            $show->field('user_phone');
            $show->field('user_address');
            $show->field('cart_id');
            $show->field('freight_price');
            $show->field('total_num');
            $show->field('total_price');
            $show->field('total_postage');
            $show->field('pay_price');
            $show->field('pay_postage');
            $show->field('deduction_price');
            $show->field('coupon_id');
            $show->field('coupon_price');
            $show->field('paid');
            $show->field('pay_time');
            $show->field('pay_type');
            $show->field('add_time');
            $show->field('status');
            $show->field('refund_status');
            $show->field('refund_reason_wap_img');
            $show->field('refund_reason_wap_explain');
            $show->field('refund_reason_time');
            $show->field('refund_reason_wap');
            $show->field('refund_reason');
            $show->field('refund_price');
            $show->field('delivery_name');
            $show->field('delivery_type');
            $show->field('delivery_id');
            $show->field('mark');
            $show->field('is_del');
            $show->field('remark');
            $show->field('mer_id');
            $show->field('is_mer_check');
            $show->field('combination_id');
            $show->field('pink_id');
            $show->field('cost');
            $show->field('seckill_id');
            $show->field('bargain_id');
            $show->field('store_id');
            $show->field('shipping_type');
            $show->field('is_channel');
            $show->field('is_remind');
            $show->field('is_system_del');
            $show->field('pid');
            $show->field('goods_id');
            $show->field('order_name');
            $show->field('created_at');
            $show->field('updated_at');
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new StoreOrder(), function (Form $form) {
            $form->display('id');
            $form->text('order_id');
            $form->text('uid');
            $form->text('real_name');
            $form->text('user_phone');
            $form->text('user_address');
            $form->text('cart_id');
            $form->text('freight_price');
            $form->text('total_num');
            $form->text('total_price');
            $form->text('total_postage');
            $form->text('pay_price');
            $form->text('pay_postage');
            $form->text('deduction_price');
            $form->text('coupon_id');
            $form->text('coupon_price');
            $form->text('paid');
            $form->text('pay_time');
            $form->text('pay_type');
            $form->text('add_time');
            $form->text('status');
            $form->text('refund_status');
            $form->text('refund_reason_wap_img');
            $form->text('refund_reason_wap_explain');
            $form->text('refund_reason_time');
            $form->text('refund_reason_wap');
            $form->text('refund_reason');
            $form->text('refund_price');
            $form->text('delivery_name');
            $form->text('delivery_type');
            $form->text('delivery_id');
            $form->text('mark');
            $form->text('is_del');
            $form->text('remark');
            $form->text('mer_id');
            $form->text('is_mer_check');
            $form->text('combination_id');
            $form->text('pink_id');
            $form->text('cost');
            $form->text('seckill_id');
            $form->text('bargain_id');
            $form->text('store_id');
            $form->text('shipping_type');
            $form->text('is_channel');
            $form->text('is_remind');
            $form->text('is_system_del');
            $form->text('pid');
            $form->text('goods_id');
            $form->text('order_name');

            $form->display('created_at');
            $form->display('updated_at');
        });
    }
}
